package com.fr.report.script;

import com.fr.base.ColumnRow;
import com.fr.base.FRContext;
import com.fr.base.StringUtils;
import com.fr.base.core.ComparatorUtils;
import com.fr.report.FineBook;
import com.fr.report.Report;
import com.fr.report.core.FormReport;
import com.fr.report.script.core.parser.ColumnRowRange;
import com.fr.report.script.core.parser.SheetIntervalLiteral;
import java.util.logging.Level;
import java.util.logging.Logger;

public class SheetInterval4CheckNameSpace
  implements NameSpace
{
  public static final SheetInterval4CheckNameSpace SC = new SheetInterval4CheckNameSpace();

  public static SheetInterval4CheckNameSpace getInstance()
  {
    return SC;
  }

  public Object getCellElementAttribute(ColumnRow paramColumnRow, Object paramObject, Calculator paramCalculator)
  {
    return null;
  }

  public Function getMethod(Object paramObject, Calculator paramCalculator)
  {
    return null;
  }

  public Object getVariable(Object paramObject, Calculator paramCalculator)
  {
    FineBook localFineBook;
    SheetIntervalLiteral localSheetIntervalLiteral;
    int i;
    if (paramObject instanceof SheetIntervalLiteral)
    {
      Report localReport1 = paramCalculator.getCurrentReport();
      if (localReport1 != null)
      {
        localFineBook = localReport1.getBook();
        localSheetIntervalLiteral = (SheetIntervalLiteral)paramObject;
        if ((localFineBook != null) && (StringUtils.isNotBlank(localSheetIntervalLiteral.getSheetName())))
          for (i = 0; i < localFineBook.getReportCount(); ++i)
            if (ComparatorUtils.equals(localFineBook.getReportName(i), localSheetIntervalLiteral.getSheetName()))
            {
              Report localReport2 = localFineBook.getReport(i);
              if (!(localReport2 instanceof FormReport))
                break;
              if (localSheetIntervalLiteral.getSheetAtom() instanceof ColumnRowRange)
                return ((FormReport)localReport2).resolveColumnRowRange((ColumnRowRange)localSheetIntervalLiteral.getSheetAtom(), null);
              FRContext.getLogger().log(Level.WARNING, "UnResolvedVariable " + localSheetIntervalLiteral.toString());
              break;
            }
      }
    }
    return null;
  }
}